gcc error message looks like this:
Code:
gcc k-hw1.c -lm -Wall -WerrorUndefined symbols for architecture x86_64:
"_Comm", referenced from:
_main in t-ebc1-ff9c31.o
"_Ind", referenced from:
_main in k-ebc1-ff9c31.o
"_Res", referenced from:
_main in k-ebc1-ff9c31.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
This is my first time ever coding and I've been scratching my head at this problem for as good couple of hours and I have no idea what I am doing at this point.
The code I used was this:
Code:
#include <stdio.h>
#include <stdlib.h>
int menu();
int Res();
int Comm();
int Ind();
int main ()
{
{
int menu ();
}
int conType;
{
printf("******Electricity Bill Calculator******\n\n");
printf("1. Residential\n");
printf("2. Commercial\n");
printf("3. Industial\n\n");
printf("0. quit program\n\n");
printf("Choose the type of connection: \n");
scanf("%d", &conType);
do
switch (conType)
{
case 1: Res();
break;
case 2: Comm();
break;
case 3: Ind();
break;
default:
printf("Invalid Choice! Please enter a valid choice: \n");
break;
}
while (conType != 0);
}
int Res();
int unit, enCharge, total;
float cuCharge; printf("Enter the number of units (in kWh): \n");
scanf("%d", &unit);
if (unit>=0 && unit<=300)
{
enCharge=unit*.075;
cuCharge=unit/(float)10;
total = enCharge+cuCharge;
}
else if (unit>=301 && unit<=750)
{
enCharge=unit*.10;
cuCharge=unit/(float)10;
total = enCharge+cuCharge;
}
else if (unit>=751 && unit <=1550)
{
enCharge=unit*.1350;
cuCharge=unit/(float)10;
total = enCharge+cuCharge;
}
else if (unit>1501)
{
enCharge=unit*.15;
cuCharge=unit/(float)10;
total = enCharge+cuCharge;
}
int Comm();
if (unit>=0 && unit<=300)
{
enCharge=unit*.300;
cuCharge=unit/(float)10;
total = enCharge+cuCharge;
}
else if (unit>=301 && unit<=750)
{
enCharge=unit*.14;
cuCharge=unit/(float)10;
total = enCharge+cuCharge;
}
else if (unit>=751 && unit <=1550)
{
enCharge=unit*.1750;
cuCharge=unit/(float)10;
total = enCharge+cuCharge;
}
else if (unit>1501)
{
enCharge=unit*.20;
cuCharge=unit/(float)10;
total = enCharge+cuCharge;
}
int Ind();
if (unit>=0 && unit<=300)
{
enCharge=unit*.36;
cuCharge=unit/(float)10;
total = enCharge+cuCharge;
}
else if (unit>=301 && unit<=750)
{
enCharge=unit*.40;
cuCharge=unit/(float)10;
total = enCharge+cuCharge;
}
else if (unit>=751 && unit <=1550)
{
enCharge=unit*.4550;
cuCharge=unit/(float)10;
total = enCharge+cuCharge;
}
else if (unit>1501)
{
enCharge=unit*.50;
cuCharge=unit/(float)10;
total = enCharge+cuCharge;
}
printf("Total Amount = %d", total);
exit (0);
}